import { zh } from './zh';
import { en } from './en';
/**
 * 正则字串是否是英文
 * @param {string} originalString
 * @return {boolean}
 */
function test(originalString: string): boolean {
  return /[a-z]/i.test(originalString);
}

const lang: string = 'zh';

/**
 * 翻译成中文
 * @param {string} originalString 原字符串
 * @return {string}
 */
function toZh(originalString: string): string {
  if (test(originalString)) {
    return zh[originalString] || originalString;
  }
  return originalString;
}

/**
 * 翻译成英文
 * @param {string} originalString  原字符串
 * @return {string}
 */
function toEn(originalString: string): string {
  console.log('toEn');
  if (test(originalString)) return originalString;
  return en[originalString] || originalString;
}
/**
 * 翻译
 * @param {string} originalString 需要翻译的字串
 * @return {string} 翻译后的字串
 */
export function translate(originalString: string): string {
  return lang == 'zh' ? toZh(originalString) : toEn(originalString);
}
